

//
//  BKPhone_Header.m
//  bestkeep
//
//  Created by yons on 16/12/15.
//  Copyright © 2016年 utouu. All rights reserved.
//

#import "BKPhone_Header.h"
#import "SDCycleScrollView.h"
#import "BKMainCommon.h"
#import "BKIntegralBookViewController.h"

@interface BKPhone_Header()<SDCycleScrollViewDelegate>


@property(nonatomic,strong)NSMutableArray *idArray;
//@property(nonatomic,strong)UIScrollView *myScrollView;
@property(nonatomic,strong)SDCycleScrollView *cycleScrollView;


@end
@implementation BKPhone_Header

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self initView];
    }
    return self;
}

-(void)initView{
    
    
    self.cycleScrollView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, self.frame.origin.y-64, self.frame.size.width, 70) delegate:self placeholderImage:[UIImage imageNamed:@"BKMain_topbanner"]];
    self.cycleScrollView.currentPageDotColor = RGBACOLOR(27, 188, 155, 1);
    self.cycleScrollView.pageDotColor = [UIColor lightGrayColor];
    self.cycleScrollView.imageURLStringsGroup = _imageArray;
    self.cycleScrollView.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.cycleScrollView];
}
-(void)setImageViewWith:(NSArray *)arr{
    NSMutableArray *itemArr = [[NSMutableArray alloc]init];
    for (NSDictionary *dic in arr) {
        NSString *img = dic[@"img"];
        [itemArr addObject:img];
        [self.codeArr addObject:dic];
    }
    self.cycleScrollView.imageURLStringsGroup = itemArr;
}

#pragma mark - SDCycleScrollViewDelegate
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index
{
    if ([self.bkPhone_headerDelegate respondsToSelector:@selector(BKPhone_headerPushVC:)]) {
        [self.bkPhone_headerDelegate BKPhone_headerPushVC:index];
    }
}
//得到视图控制器
- (UIViewController *)viewController {
    for (UIView* next = [self superview]; next; next = next.superview) {
        UIResponder *nextResponder = [next nextResponder];
        if ([nextResponder isKindOfClass:[UIViewController class]]) {
            return (UIViewController *)nextResponder;
        }
    }
    return nil;
}

-(NSMutableArray *)codeArr{
    if (!_codeArr) {
        _codeArr = [[NSMutableArray alloc]init];
    }
    return _codeArr;
}
@end
